package com.StarStudio.DAO;

import com.ruoyi.common.core.Entity.PanicBuyingOrders;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PanicBuyingOrdersDAO {

    List<PanicBuyingOrders> findPanicBuyingOrdersList(PanicBuyingOrders panicBuyingOrders);

    @Select("select count(*) from panic_buying_orders where del_flag = false")
    long findTotalRecord();

    @Insert("insert into panic_buying_orders values (#{panic_buying_order_id},#{user_id},#{order_id},#{goods_id},#{coupons_id},#{del_flag})")
    void addPB_order(PanicBuyingOrders panicBuyingOrders);

    Long findPanicBuyingGoodsOrderId(@Param("user_id") long user_id, @Param("thingsId") long thingsId, @Param("date")String date);

    Long findPanicBuyingCouponsOrderId(@Param("user_id")long user_id, @Param("thingsId") long thingsId, @Param("date")String date);

    List<PanicBuyingOrders> findStorePanicBuyingOrdersList(@Param("pbo") PanicBuyingOrders pbo,@Param("storeId") Long storeId);

    long findStoreTotalRecord(Long userId);

    List<PanicBuyingOrders> findPanicBuyingGoodsOrdersList(PanicBuyingOrders panicBuyingOrders);
    List<PanicBuyingOrders> findPanicBuyingCouponsOrdersList(PanicBuyingOrders panicBuyingOrders);

    List<PanicBuyingOrders> findStorePanicBuyingGoodsOrdersList(@Param("pbo") PanicBuyingOrders pbo,@Param("storeId") Long storeId);

    @Select("select count(*) from panic_buying_orders where del_flag = false and coupons_id is null")
    long findPanicBuyingGoodsOrdersTotalRecord();

    long findStorePanicBuyingGoodsOrdersTotalRecord(Long storeId);

    List<PanicBuyingOrders> findStorePanicBuyingCouponsOrdersList(@Param("pbo") PanicBuyingOrders pbo,@Param("storeId") Long storeId);

    @Select("select count(*) from panic_buying_orders where del_flag = false and goods_id is null")
    long findPanicBuyingCouponsOrdersTotalRecord();

    long findStorePanicBuyingCouponsOrdersTotalRecord(Long storeId);

    List<Long> findUserIdListByGoodsId(Long goodsId);

    List<Long> findUserIdListByCouponsId(Long couponsId);
}
